package cn.edu.neusoft.demo.hospital2.Controller;

import cn.edu.neusoft.demo.hospital2.Service.CarouselService;
import cn.edu.neusoft.demo.hospital2.pojo.Carousel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")
@Tag(name = "轮播图相关的api")
@RequestMapping("/carousel")
public class CarouselController {
    @Autowired
    private CarouselService carouselService;

    @Operation(summary = "查询所有轮播图",description = "查询所有轮播图")
    @GetMapping("/all")
    public List<Carousel> selectAll() {
        return carouselService.selectAll();
    }

    @Operation(summary = "查询轮播图",description = "查询轮播图")
    @GetMapping("/{id}")
    public Carousel selectById(int id){
        return carouselService.selectById(id);
    }

    @Operation(summary = "插入轮播图",description = "插入轮播图")
    @PostMapping("/insert")
    public int insert(Carousel carousel){
        return carouselService.insert(carousel);
    }

    @Operation(summary = "更新轮播图",description = "更新轮播图")
    @PutMapping("/update")
    public int update(Carousel carousel){
        return carouselService.update(carousel);
    }

    @Operation(summary = "删除轮播图",description = "删除轮播图")
    @DeleteMapping("/delete/{id}")
    public int deleteById(@PathVariable int id){
        return carouselService.deleteById(id);
    }
}
